package cn.com.open.itembank.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * 策略模块（部分）.
 */
public class RulePart {
    /**
     * Instantiates a new Rule part.
     */
    public RulePart() {
        mediaType = 0;
        ruleSections = new ArrayList<>();
        timeLimits = new TimeLimits();
    }

    /**
     * The Rule sections.
     */
    private List<RuleSection> ruleSections;

    /**
     * 媒体类型.
     */
    private Integer mediaType;

    /**
     * 必考题和例题及答题说明、检查时间占用时间.
     */
    private Integer durationFixed;

    /**
     * 时间限制.
     */
    private TimeLimits timeLimits;

    /**
     * Gets rule sections.
     *
     * @return the rule sections
     */
    public List<RuleSection> getRuleSections() {
        if (ruleSections == null) {
            ruleSections = new ArrayList<>();
        }
        return ruleSections;
    }

    /**
     * Gets media type.
     *
     * @return the media type
     */
    public Integer getMediaType() {
        return mediaType;
    }

    /**
     * Sets media type.
     *
     * @param mediaType the media type
     */
    public void setMediaType(Integer mediaType) {
        this.mediaType = mediaType;
    }

    /**
     * Gets duration fixed.
     *
     * @return the duration fixed
     */
    public Integer getDurationFixed() {
        return durationFixed;
    }

    /**
     * Sets duration fixed.
     *
     * @param durationFixed the duration fixed
     */
    public void setDurationFixed(Integer durationFixed) {
        this.durationFixed = durationFixed;
    }

    /**
     * Gets time limits.
     *
     * @return the time limits
     */
    public cn.com.open.itembank.dto.TimeLimits getTimeLimits() {
        return timeLimits;
    }

    /**
     * Sets time limits.
     *
     * @param timeLimits the time limits
     */
    public void setTimeLimits(cn.com.open.itembank.dto.TimeLimits timeLimits) {
        this.timeLimits = timeLimits;
    }

    /**
     * Instantiates a new Rule part.
     *
     * @param curMediaType the cur media type
     */
    public RulePart(Integer curMediaType) {
        mediaType = curMediaType;
        ruleSections = new ArrayList<>();
        timeLimits = new TimeLimits();
    }

    /**
     * copy rule part.
     *
     * @return the rule part
     */
    public RulePart copy() {
        RulePart copy = new RulePart(this.mediaType);
        copy.durationFixed = durationFixed;

        for (RuleSection ruleSection : ruleSections) {
            copy.ruleSections.add(ruleSection.copy());
        }

        copy.timeLimits.setCheckTime(timeLimits.getCheckTime());
        copy.timeLimits.setMinTime(timeLimits.getMinTime());
        copy.timeLimits.setMaxTime(timeLimits.getMaxTime());
        copy.timeLimits.setExpectedTime(timeLimits.getExpectedTime());

        return copy;
    }
}
